const fs = require('fs')
const path = require('path')
const JSON5 = require('json5')
const Mock = require('mockjs') 
const { get } = require('core-js/core/dict')
const jsonServer = require('json-server')

function getJsonFile(filePath){
    var json = fs.readFileSync(path.join(__dirname,filePath),'utf-8')

    let obj = JSON5.parse(json);

    return obj;
}

// 返回一个函数
module.exports = function(app){
    //监听
    app.get('/api/users',function(req,res){
        var json = getJsonFile('./data.json5');
        res.json(Mock.mock(json));
    });
}